package edu.hue.jk.service;

import edu.hue.jk.Mapper.RoomDao;
import edu.hue.jk.Mapper.StudentDao;
import edu.hue.jk.entity.Room;
import edu.hue.jk.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;

import java.util.List;

@Service
public class RoomService {
    @Autowired
    private RoomDao roomDao;

    @Autowired
    private StudentDao studentDao;

    @Autowired
    private StudentService studentService;

    public String selectroom_1(int did, Model model){
        List<Room> roomList=roomDao.queryById(did);
        model.addAttribute("roomList",roomList);
        return "selectroom_1";
    }
    public String list(Model model){
        List<Student> studentList=studentDao.selectAll();
        model.addAttribute("studentList",studentList);
        return "studentlist";
    }
    public String add(){
        return "addstudent";
    }

    public String delete(Model model,String sid){
        return studentService.delete(model, sid);
    }

    public String update(Student student,Model model){
        return studentService.update(student,model);
    }

    public String updates(String sid,Model model){
        Student student=studentDao.queryById(sid);
        model.addAttribute("student",student);
        return "updatestudent";
    }

}
